package com.ssfGame.puremvc.view.application
{
	 
	import com.game.alert.AlertCtrl;
	import com.game.tips.TipCtrl;
	import com.game.utils.GlobalFun;
	import com.ssfGame.common.MouseCursor;
	import com.ssfGame.puremvc.StaticConst;
	import com.ssfGame.puremvc.model.ConfigProxy;
	import com.ssfGame.puremvc.model.vo.ConfigVO;
	import com.ssfGame.puremvc.view.module.Game.GameMediator;
	import com.ssfGame.puremvc.view.module.gameOver.GameOverMediator;
	import com.ssfGame.puremvc.view.module.title.TitleMediator;
	import com.ssfGame.puremvc.view.vc.APILayerVC;
	import com.ssfGame.puremvc.view.vc.ControlLayerVC;
	import com.ssfGame.puremvc.view.vc.GuideLayerVC;
	import com.ssfGame.puremvc.view.vc.LoadLayerVC;
	import com.ssfGame.puremvc.view.vc.MouseLayerVC;
	import com.ssfGame.puremvc.view.vc.PopupLayerVC;
	import com.ssfGame.puremvc.view.vc.SceneLayerVC;
	import com.ssfGame.puremvc.view.vc.TipLayerVC;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * 
	 * @author chery
	 */
	public class ApplicationMediator extends Mediator
	{
		private var _isCommLoader:Boolean=false;
		private var _isMapLoader:Boolean=false;
		private var isUserInfoLoader:Boolean=false;
		/**
		 * 
		 * @default 
		 */
		public static const NAME:String="ApplicationMediator"
		/**
		 * 
		 * @param mediatorName
		 * @param viewComponent
		 */
		public function ApplicationMediator(mediatorName:String=null, viewComponent:Object=null)
		{
			super(mediatorName, viewComponent);
		}
	
		override public function onRegister():void{
			var _configVO:ConfigVO=(facade.retrieveProxy(ConfigProxy.NAME) as ConfigProxy).configVO;;
			StaticConst.appStage=main.stage;
			StaticConst.configVO = _configVO;
			
			
			var sceneLayerVC:SceneLayerVC = new SceneLayerVC();
			var controlLayerVC:ControlLayerVC = new ControlLayerVC();
			var popupLayerVC:PopupLayerVC = new PopupLayerVC();	
			var tipLayerVC:TipLayerVC = new TipLayerVC();
			var loadLayerVC:LoadLayerVC = new LoadLayerVC();
			var mouseLayerVC:MouseLayerVC = new MouseLayerVC();
			var _apiLayerVC:APILayerVC=new APILayerVC();
			
			facade.registerMediator(new SceneLayerMediator(SceneLayerMediator.NAME,sceneLayerVC));
			facade.registerMediator(new ControlLayerMediator(ControlLayerMediator.NAME,controlLayerVC));
			facade.registerMediator(new PopupLayerMediator(PopupLayerMediator.NAME,popupLayerVC));
			facade.registerMediator(new TipLayerMediator(TipLayerMediator.NAME,tipLayerVC));
			facade.registerMediator(new LoadLayerMediator(LoadLayerMediator.NAME,loadLayerVC));
			facade.registerMediator(new MouseLayerMediator(MouseLayerMediator.NAME,mouseLayerVC));
			facade.registerMediator(new APILayerMediator(APILayerMediator.NAME,_apiLayerVC));
			
			
			
			facade.registerMediator(new TitleMediator(TitleMediator.NAME));
			facade.registerMediator(new GameMediator(GameMediator.NAME));
			facade.registerMediator(new GameOverMediator(GameOverMediator.NAME));
			
			
			
			
			main.addChild(sceneLayerVC);
			main.addChild(_apiLayerVC);
			main.addChild(controlLayerVC);
			main.addChild(popupLayerVC);
			main.addChild(loadLayerVC);
			main.addChild(tipLayerVC);
			main.addChild(mouseLayerVC);
			
			sendNotification(StaticConst.N_M_SCENE_LAYER_ADD,GlobalFun.getRect(main.stage.stageWidth,main.stage.stageHeight));
			
			TipCtrl.getInstance().oParent = tipLayerVC;
			AlertCtrl.getInstance().oParent = tipLayerVC;
			MouseCursor.init(mouseLayerVC, main.stage);
			sendNotification(StaticConst.N_C_LOAD_CONFIG);
		}
		
		/**
		 * 
		 * @return 
		 */
		protected function get main():Demo_PVP_builder_MVC{
			return viewComponent as Demo_PVP_builder_MVC
		}
	}
}